package com.haiqiu.tools.test.controller;

import com.haiqiu.tools.common.utils.HttpServletUtils;
import com.haiqiu.tools.word.utils.WordUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * @author HaiQiu
 * @date 2022/9/26
 */
@RestController
@RequestMapping("/word")
public class WordController {

    @RequestMapping("/pdf")
    public void test() throws Exception {
        Map<String,Object> params = new HashMap<>();
        params.put("${school}","清华大学东南分校区");
        params.put("${name}","张倩倩");
        params.put("${dept}","财务部");
        params.put("${post}","财务总监");
        params.put("${price}","8000.00");
        params.put("${year}","2022");
        params.put("${mouth}","08");
        params.put("${day}","30");
        params.put("${图片标记}","http://221.182.8.141:10090/static/img/tubiao.db87f024.png");
        WordUtils.exportPdf("template/离职证明.docx", params,"离职证明");
    }

    @RequestMapping("/docx")
    public void docx() throws Exception {
        Map<String,Object> params = new HashMap<>();
        params.put("${school}","清华大学东南分校区");
        params.put("${name}","张倩倩");
        params.put("${dept}","财务部");
        params.put("${post}","财务总监");
        params.put("${price}","8000.00");
        params.put("${year}","2022");
        params.put("${mouth}","08");
        params.put("${day}","30");
        params.put("${图片标记}","http://221.182.8.141:10090/static/img/tubiao.db87f024.png");
        WordUtils.exportDocx("template/离职证明.docx", params,"离职证明");
    }
}
